﻿<navigation:Page 
    x:Class="ibba.src.noriskbo.PageReserva" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:sdk="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"    
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
    xmlns:dataPrimitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data"
    xmlns:converter="clr-namespace:ibba.src.noriskbo.code.converter"
    xmlns:slc="clr-namespace:ibba.src.sl.componentes;assembly=ibba.src.sl.componentes"      
    mc:Ignorable="d"
    d:DesignWidth="1015" d:DesignHeight="500" MinHeight="550"
    Title="Reservas" 
    FontSize="10.667" >

    <navigation:Page.Resources>        
        <converter:CategoriaConverter x:Key="CategoriaConverter" />

        <Style x:Key="CenterAlignStyle" TargetType="TextBlock">
            <Setter Property="TextAlignment" Value="Center" />
        </Style>
        <Style x:Key="RightAlignStyle" TargetType="TextBlock">
            <Setter Property="TextAlignment" Value="Right" />
        </Style>
        <Style x:Key="WordWrapp" TargetType="TextBlock">
            <Setter Property="TextWrapping" Value="Wrap" />
        </Style>
        <Style TargetType="dataPrimitives:DataGridColumnHeader" x:Key="headerStyle">
            <Setter Property="ContentTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <TextBlock Text="{Binding}" TextWrapping="Wrap" HorizontalAlignment="Center" />
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </navigation:Page.Resources>

    <Grid x:Name="LayoutRoot" >
        <Grid.RowDefinitions>
            <RowDefinition Height="0"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="0"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="10"/>
            <ColumnDefinition Width="0.918*"/>
            <ColumnDefinition Width="10"/>
        </Grid.ColumnDefinitions>

        <toolkit:BusyIndicator x:Name="activity" Grid.Row="1" Grid.Column="1">

            <Grid Background="#FFFFFFFF" Grid.Column="1" Grid.Row="1">

                <Grid.RowDefinitions>
                    <RowDefinition Height="28"/>
                    <!-- panel label limites -->
                    <RowDefinition Height="23"/>
                    <!-- panel text's limites -->
                    <RowDefinition Height="30"/>
                    <!-- panel label sulimites -->
                    <RowDefinition Height="0.25*"/>
                    <!-- panel grid sulimites -->
                    <RowDefinition Height="35"/>
                    <!-- panel label reserva -->
                    <RowDefinition Height="0.28*"/>
                    <!-- panel grid reserva -->
                </Grid.RowDefinitions>

                <TextBlock Name="lblTituloPagina" Text="Titulo da Pagina" Style="{StaticResource TitlePage}" Grid.RowSpan="6" />
                
                <StackPanel Name="spLabelLimite" Orientation="Vertical" Margin="5,8,0,0" Grid.Row="0" Visibility="Collapsed">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Name="lblLimites" Text="Limite do Grupo: " FontSize="12" Foreground="#FFE78E21" />
                        <TextBlock Name="lblNomeGrupo" Text="" Margin="5,0,0,0" FontSize="12" Foreground="#FFE78E21"/>
                    </StackPanel>
                    <Border Style="{StaticResource LineGold}" HorizontalAlignment="Left"/>
                </StackPanel>

                <StackPanel Name="spLimite" Orientation="Horizontal" Margin="5,5,0,0" Grid.Row="1" Visibility="Collapsed">
                    <TextBlock Name="lbTituloVlReais" Text="Limite em Reais:" Margin="0,0,0,0" FontSize="12" />
                    <TextBlock Name="lbVlReais" Text="0.00" MinWidth="115" TextAlignment="Left" Margin="5,0,0,0" FontSize="12" Foreground="#FF1F3C65" />

                    <TextBlock Name="lbTituloVlUtilizado" Text="Utilizado:" Margin="15,0,0,0" FontSize="12" />
                    <TextBlock Name="lbVlUtilizado" Text="0.00" MinWidth="115" TextAlignment="Left" Margin="5,0,0,0" FontSize="12" Foreground="#FF1F3C65" />

                    <TextBlock Name="lbTituloVlReservado" Text="Reservado:" Margin="15,0,0,0" FontSize="12" />
                    <TextBlock Name="lbVlReservado" Text="0.00" MinWidth="115" TextAlignment="Left" Margin="5,0,0,0" FontSize="12" Foreground="#FF1F3C65" />

                    <TextBlock Name="lbTituloVlDisponivel" Text="Disponível:" Margin="15,0,0,0" FontSize="12" />
                    <TextBlock Name="lbVlDisponivel" Text="0.00" MinWidth="115" TextAlignment="Left" Margin="5,0,0,0" FontSize="12" Foreground="#FF1F3C65" />
                </StackPanel>

                <TextBlock Name="lblResultadoLimite" Text="Nenhum Limite encontrado." Grid.Row="1" Margin="5,5,0,0" FontSize="12" Visibility="Collapsed" />

                <StackPanel Name="spLabelSubLimites" Orientation="Vertical" Margin="5,8,0,0" Grid.Row="2"  Visibility="Collapsed">
                    <TextBlock Name="lbSubLimites" Height="20" Text="Sublimites" FontSize="12" Foreground="#FFE78E21" />
                    <Border Style="{StaticResource LineGold}" HorizontalAlignment="Left"/>
                </StackPanel>

                <TextBlock Name="lblResultadoSublimite" Text="Nenhum sublimite encontrado." Grid.Row="3" Margin="5,10,0,0" FontSize="12" Visibility="Collapsed" />

                <sdk:DataGrid x:Name ="grdSublimites" ColumnHeaderStyle="{StaticResource headerStyle}"  
                              BorderThickness="1" Margin="5,5,5,0" Grid.Row="3" 
                              AlternatingRowBackground="#FFFCFCFC" 
                              RowBackground="#FFFCFCFC" 
                              AutoGenerateColumns="False" 
                              IsReadOnly="True" 
                              HorizontalScrollBarVisibility="Auto"                              
                              GridLinesVisibility="All" d:LayoutOverrides="Width"
                              Visibility="Collapsed" 
                              SelectionChanged="grdSublimites_SelectionChanged">
                    <sdk:DataGrid.Columns>
                        <sdk:DataGridTextColumn Header="Descrição" MinWidth="224" Width="224*" Binding="{Binding Descricao}"  ElementStyle="{StaticResource WordWrapp}"/>
                        <sdk:DataGridTextColumn Header="Limite em Reais"  Width="125" MinWidth="125" Binding="{Binding ValorLimite, Converter={StaticResource DecimalConverter}}"
                                                ElementStyle="{StaticResource RightAlignStyle}"/>
                        <sdk:DataGridTextColumn Header="Utilizado" Width="125" MinWidth="125" Binding="{Binding ValorUtilizado, Converter={StaticResource DecimalConverter}}" 
                                                ElementStyle="{StaticResource RightAlignStyle}" />
                        <sdk:DataGridTextColumn Header="Reservado" Width="125" MinWidth="125" Binding="{Binding ValorReservado, Converter={StaticResource DecimalConverter}}" 
                                                ElementStyle="{StaticResource RightAlignStyle}" />
                        <sdk:DataGridTextColumn Header="Disponível" Width="125" MinWidth="125" Binding="{Binding ValorDisponivel, Converter={StaticResource DecimalConverter}}" 
                                                ElementStyle="{StaticResource RightAlignStyle}" />
                        <sdk:DataGridTextColumn Header="Runoff" Width="56" MinWidth="56" Binding="{Binding Runoff, Converter={StaticResource RunOffConverter}}"
                                                ElementStyle="{StaticResource CenterAlignStyle}" />
                        <sdk:DataGridTextColumn Header="Status" Width="56" MinWidth="56" Binding="{Binding Categoria, Converter={StaticResource CategoriaConverter}}"/>
                        <sdk:DataGridTextColumn Header="Reservas" Width="70" MinWidth="70" Binding="{Binding QtdReservas}"  
                                                ElementStyle="{StaticResource CenterAlignStyle}"/>
                    </sdk:DataGrid.Columns>
                </sdk:DataGrid>

                <Grid Grid.Row="4" Margin="5,0,0,0" Visibility="Visible" MinWidth="850">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="0.5*"/>
                        <ColumnDefinition Width="0.5*"/>
                    </Grid.ColumnDefinitions>
                    <StackPanel Name="splblFiltroReservas" Grid.Column="0" Orientation="Vertical" Margin="0,15,0,0" Visibility="Collapsed">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Name="lblFiltroReservas" Text="Reservas" Foreground="#FFE78E21" FontSize="12" />
                            <TextBlock Name="lblNomeGrupoReserva" Text="" Margin="5,0,0,0" FontSize="12" Foreground="#FFE78E21"/>
                        </StackPanel>
                        <Border Style="{StaticResource LineGold}" HorizontalAlignment="Left"/>
                    </StackPanel>
                    <StackPanel Grid.Column="1" Name="spFiltroReservas" HorizontalAlignment="Right" Orientation="Horizontal" Visibility="Collapsed" >
                        <Border Style="{StaticResource borderOpcaoFiltro}"
                                    HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="2,2,5,-2">
                            <StackPanel Orientation="Horizontal" Height="16">
                                <TextBlock Text="Filtro: " HorizontalAlignment="Left" Style="{StaticResource SubTitleHeader}" FontSize="11" Height="16"/>
                                <Image Source="{StaticResource IconeFiltro}" Height="16" Width="16" />
                                <CheckBox Name="chkFiltroReservaLimiteGlobal" Content="Reservas do Limite Global" Click="chkFiltroReserva_Click" Margin="20,0,0,0" Foreground="Black"  />
                                <CheckBox Name="chkFiltroReservaLimite" Content="Reservas do Sublimite" Margin="10,0,0,0" Click="chkFiltroReserva_Click" Foreground="Black"  />
                            </StackPanel>
                        </Border>
                    </StackPanel>
                </Grid>

                <TextBlock Name="lblResultadoReserva" Text="Nenhuma reserva encontrada." Grid.Row="5" 
                           Margin="5,10,0,0" FontSize="12" Visibility="Collapsed" />

                <Grid Margin="5,5,5,8" Grid.Row="5" >

                    <sdk:DataGrid x:Name ="grdReservas" 						           
                                  AlternatingRowBackground="#FFFCFCFC" 
                                  AutoGenerateColumns="False"
                                  RowBackground="#FFFCFCFC" Width="auto" 
							      IsReadOnly="True"
							      GridLinesVisibility="All" 
                                  Visibility="Collapsed"
                                  BorderThickness="1"
                                  Margin="0,0,0,10">
                        <sdk:DataGrid.Columns>

                            <sdk:DataGridTemplateColumn MinWidth="25" Width="25" Visibility="Collapsed">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button x:Name="btnAlterarReserva" IsEnabled="True" Click="btnAlterarReserva_Click" >
                                            <Image Source="{StaticResource BotaoEditar}" Width="16" Height="16" />
                                            <ToolTipService.ToolTip>
                                                <ToolTip Content="Alterar"></ToolTip>
                                            </ToolTipService.ToolTip>
                                        </Button>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>

                            <sdk:DataGridTemplateColumn MinWidth="25" Width="25" Visibility="Collapsed">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button x:Name="btnExcluirReserva" IsEnabled="True" Click="btnExcluirReserva_Click">
                                            <Image Source="{StaticResource IconeRemover}" Width="16" Height="16" />
                                            <ToolTipService.ToolTip>
                                                <ToolTip Content="Excluir"></ToolTip>
                                            </ToolTipService.ToolTip>
                                        </Button>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>

                            <sdk:DataGridTextColumn Header="Número" Width="140" MinWidth="130" Binding="{Binding Contrato}" 
                                                    ElementStyle="{StaticResource WordWrapp}"/>
                            <sdk:DataGridTextColumn Header="Cliente" Width="170" MinWidth="110" Binding="{Binding NomeCliente}" 
                                                    ElementStyle="{StaticResource WordWrapp}"/>
                            <sdk:DataGridTextColumn Header="Sublimite" Width="400*" MinWidth="260" Binding="{Binding DescricaoSublimite}" 
                                                    ElementStyle="{StaticResource WordWrapp}"/>
                            <sdk:DataGridTextColumn Header="Área Sublimite" Width="100" Binding="{Binding DescAreaSubLimite}" 
                                                    ElementStyle="{StaticResource WordWrapp}"/>
                            <sdk:DataGridTextColumn Header="Motivo" Width="240*" MinWidth="240" Binding="{Binding Observacao}"
                                                    ElementStyle="{StaticResource WordWrapp}"/>
                            <sdk:DataGridTextColumn Header="Abertura" Width="75" MinWidth="75" Binding="{Binding Path=DataAbertura, Converter={StaticResource DateTimeConverter}}"
                                                    ElementStyle="{StaticResource CenterAlignStyle}" />
                            <sdk:DataGridTextColumn Header="Vencimento" Width="85" MinWidth="85" Binding="{Binding DataVencimento, Converter={StaticResource DateTimeConverter}}"  
                                                    ElementStyle="{StaticResource CenterAlignStyle}"/>
                            <sdk:DataGridTextColumn Header="Usuário" Width="170" MinWidth="100" Binding="{Binding Usuario}" 
                                                    ElementStyle="{StaticResource WordWrapp}"/>
                            <sdk:DataGridTextColumn Header="Valor" Width="125" MinWidth="120" Binding="{Binding Path=Valor, Converter={StaticResource DecimalConverter}}"
                                                    ElementStyle="{StaticResource RightAlignStyle}" />

                        </sdk:DataGrid.Columns>
                    </sdk:DataGrid>

                    <toolkit:BusyIndicator x:Name="activityReservas" />

                </Grid>
            </Grid>

        </toolkit:BusyIndicator>
    </Grid>

</navigation:Page>
